<template>
  <el-container>
    <avue-form :option="option" v-model="form" @submit="handleDebug">
    </avue-form>
  </el-container>
</template>
<script>
import {
  debug,
} from "@/api/system/ruleManage";
import flowDesign from "./components/flowDesign";
export default {
  components: {
    flowDesign,
  },
  data() {
    return {
      dicData: [],
      id: '',
      form: {
        list: [{
          characteristicCode: '',
          value: ''
        }]
      },
      option: {
        submitText: '调试',
        column: [
          {
            label: '特征集合',
            prop: 'list',
            type: 'dynamic',
            span: 24,
            children: {
              index: false,
              align: 'center',
              type: 'form',
              headerAlign: 'center',
              rowAdd: (done) => {
                // this.$message.success('新增回调');
                done();
              },
              rowDel: (row, done) => {
                // this.$message.success('删除回调' + JSON.stringify(row));
                done();
              },
              column: [{
                label: '报告单',
                prop: 'caseReportCode',
                type: 'cascader',
                // props: {
                //   label: 'label',
                //   value: 'value'
                // },
                dicUrl: '/api/blade-platform/rule/threelinkage'
              }, {
                width: 200,
                label: '值',
                prop: "value"
              },]
            }
          },
        ]
      }
    }
  },
  mounted() {
    this.id = this.$route.query.id
  },
  methods: {
    handleDebug(form, done) {
      const arr = []
      form.list.forEach(element => {
        arr.push({
          caseReportCode: element.caseReportCode.length >= 0 ? element.caseReportCode[0] : '',
          characteristicCode: element.caseReportCode.length >= 1 ? element.caseReportCode[1] : '',
          targetCode: element.caseReportCode.length >= 2 ? element.caseReportCode[2] : '',
          value: element.value
        })
      });
      console.log('规则调试数据', JSON.stringify(form));
      const data = {
        id: this.id,
        roleParameterDTOs: arr
      }
      console.log('规则调试-处理后数据', JSON.stringify(data));
      debug(data).then((res) => {
        const data=res.data.data
        done()
        this.$alert(data, '调试结果')
        console.log(res);
      })
    },
    next() {
      this.activeName = 'second'
      this.secondDisabled = false
      this.firstDisabled = true
    }
  }
}
</script>
